home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_03
/
allison
/
preproc.c
< prev
next >
Wrap
Text File
|
1994-01-05
|
707b
|
36 lines
LISTING 8 - Illustrates macro rescanning
/* preproc.c: Test # and ## preprocessing operators
*
* NOTE: DO NOT COMPILE! Preprocess only!
*/
/* Handy stringizing macros */
#define str(s) #s
#define xstr(s) str(s)
/* Handy token-pasting macors */
#define glue(a,b) a##b
#define xglue(a,b) glue(a,b)
/* Some definitions */
#define ID(x) "This is version " ## xstr(x)
#define INCFILE(x) xstr(glue(version,x)) ".h"
#define VERSION 2
#define ION ATILE
/* Expand some macros */
str(VERSION)
xstr(VERSION)
glue(VERSION,3)
xglue(VERSION,3)
glue(VERS,ION)
xglue(VERS,ION)
/* Expand some more */
ID(VERSION)
INCFILE(VERSION)
str(INCFILE(VERSION))
xstr(INCFILE(VERSION))